<template>
  <layout>
    <!-- 查看文件上传内容 -->
    <!-- 顶部操作 -->
    <!-- <section slot="search"> -->
      <!-- <custom-form
        ref="search-form"
        class="search-form"
        v-model="tableSearch"
        layout="inline"
        mode="search"
        :FormList="searchColumns"
      >
        <a-button
          class="action-button"
          type="primary"
          @click="search()"
        >搜索</a-button>
        
      </custom-form> -->
    <!-- </section> -->

    <!-- 产品列表 -->
    <a-table
      :dataSource="tableData"
      :columns="tableColumns"
      :rowKey="record => record.member_id"
      :customRow="customTableRow"
      :pagination="false"
      size='small'
      :scroll="{
        x: '100%',
        y: 520
      }"
      bordered
    >
      <!-- 按钮区 -->
      
    </a-table>

    <a-pagination
      slot="paging"
      :pageSizeOptions="pageSizes"
      :total="total"
      :show-total="showTotal"
      showSizeChanger
      :pageSize="pageSize"
      v-model="currentPage"
      @showSizeChange="changePageSize"
      @change="changePage"
    >
    </a-pagination>
  </layout>
</template>

<script lang="ts">
import { Mixins, Component, Watch, Vue, Prop } from 'vue-property-decorator'
import { State, Mutation, Getter, namespace } from 'vuex-class'
import EventsMixin from '@/mixin/events'
import { TableMixin, AuthMixin } from '@/mixin'
import { userModule } from '@/store/modules/user'

import { TableLayout } from '@/layouts'
import CustomForm from '@/components/src/Form'
import { userServices, IAdmin } from '@/common/services'
import { commonServices } from '@/common/services/common'
import { subsidyServices, IStatistics } from '@/common/services/subsidy'
import { payServices, IBankReceiptBasic } from '@/common/services/pay'
import { memberRole } from '@/common/enum'

import XLSX from 'xlsx'

@Component({
  components: {
    Layout: TableLayout,
    CustomForm,
  }
})
export default class AdminList extends Mixins(
  EventsMixin,
  TableMixin,
  AuthMixin
) {
  @Prop({
    type: Array
  })
  public execlData!: Array<any>

  @Prop({
    type: Boolean,
    default: true
  })
  public isMember!: boolean

  public commonParams = {
    s_a_id: ''
  }

  // 产品列表搜索条件
  public tableSearch = {
  }

  // 自定义mode
  public customMode = 'search'

  get calcColumns () {
    return [
      {
        title: '农户编号',
        dataIndex: 'member_id',
        key: 'member_id',
        width: 180
      },
      {
        title: this.isMember ? '农户姓名' : '姓名',
        dataIndex: 'member_nam',
        key: 'member_nam',
        width: 80
      },
      {
        title: this.isMember ? '身份证号' : '身份证号码',
        dataIndex: 'member_sfz',
        key: 'member_sfz',
        width: 180
      },
      {
        title: '户口本号',
        dataIndex: 'family_book_id',
        key: 'family_book_id',
        width: 150
      },
      {
        title: '农户性别',
        dataIndex: 'member_sex',
        key: 'member_sex',
        width: 80
      },
      {
        title: this.isMember ? '联系电话(或村委会电话)' : '联系电话',
        dataIndex: 'member_tel',
        key: 'member_tel',
        width: 170
      },
      {
        title: '银行账号',
        dataIndex: 'member_bank_num',
        key: 'member_bank_num',
        width: 180
      },
      {
        title: '开户银行',
        dataIndex: 'member_bank_code',
        key: 'member_bank_code',
        width: 140
      },
      {
        title: '家庭住址',
        dataIndex: 'member_addr',
        key: 'member_addr',
        width: 240
      },
      // {
      //   title: '原计税面积',
      //   dataIndex: 'bt_size_old',
      //   key: 'bt_size_old',
      //   width: 90
      // },
      // {
      //   title: '水田面积',
      //   dataIndex: 'water',
      //   key: 'water',
      //   width: 80
      // },
      // {
      //   title: '旱地面积',
      //   dataIndex: 'field',
      //   key: 'field',
      //   width: 80
      // },
      // {
      //   title: '粮食播种面积',
      //   dataIndex: 'plant',
      //   key: 'plant',
      //   width: 120
      // },
      {
        title: '备注',
        dataIndex: 'readme',
        key: 'readme',
        width: 200
      },
    ]
  }

  // 产品列表表格信息
  public columns: ITable.IColumn[] = []

  public tableApi = {
    list: payServices.getBankReceipts,
    // add: famerServices.updateMemberGrain,
    // edit: payServices.editBankReceipt,
    // del: payServices.delBank,
    // imageUpload: 'uploadStoreImage',
    // imageRemove: 'delStoreImage'
  }

  @Watch('isMember', { immediate: true })
  public handlerChangeIsMember() {
    this.columns = this.isMember ? this.calcColumns : [
      {
        title: '是否享受',
        dataIndex: 'zt',
        key: 'zt',
        width: 80
      },
    ].concat(this.calcColumns);
  }

  @Watch('execlData', { immediate: true })
  public handlerChangeExecl() {
    this.total = this.execlData.length
    this.getData()
  }

  public mounted() {
    // this.tableData = this.execlData || []
  }

  public async getData() {
    // const res = await this.getTableList()
    this.tableData = this.execlData.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize)
    // this.tableData = []
  }
}
</script>

<style scoped lang="less">
.action-button {
  margin: 0px 10px 0px 10px;
}
.upload-button {
  position: relative;
  input {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 2;
    opacity: 0;
  }
}
.form-item-class {
  margin-bottom: 0px;
}
.img-box {
  width: 100px;
  height: 100px;
  margin: 10px;
}
.item-blue {
  color: #1989fa;
}
</style>
